//-----------------------------------------------------------------------
//  This file was part of the Microsoft Robotics Studio Code Samples.
// 
//  Copyright (C) Microsoft Corporation.  All rights reserved.
//
//  $File: DashboardState.cs $ $Revision: 8 $
//
// May-2007:
// Added options for displaying a map
//
// Jun-2007:
// Added a webcam viewer
//
// Oct-2007:
// Some minor changes for ProMRDS
//
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using Microsoft.Dss.Core.Attributes;
using drive = Microsoft.Robotics.Services.Drive.Proxy;
// TT - Changed in Oct CTP
//using sicklrf = Microsoft.Robotics.Services.Samples.Drivers.SickLRF.Proxy;
using sicklrf = Microsoft.Robotics.Services.Sensors.SickLRF.Proxy;

// For documentation attributes
using System.ComponentModel;


namespace ProMRDS.Robotics.Services.Dashboard
{
    /// <summary>
    /// Dashboard State
    /// </summary>
    [DataContract]
    [DisplayName("Dashboard State")]
    [Description("Properties used to configure the Dashboard")]
    public class DashboardState
    {
        private bool _log;
        private string _logFile;
        private string _machine;
        private ushort _port;

        /// <summary>
        /// Log Flag
        /// </summary>
        /// <remarks>Turns Logging on/off</remarks>
        [DataMember]
        [DisplayName("Log Flag")]
        [Description("Turns Logging on/off")]
        public bool Log
        {
            get { return _log; }
            set { _log = value; }
        }
        /// <summary>
        /// Log File Name
        /// </summary>
        /// <remarks>Full name of the Log File</remarks>
        [DataMember]
        [DisplayName("Log File Name")]
        [Description("Full name of the Log File")]
        public string LogFile
        {
            get { return _logFile; }
            set { _logFile = value; }
        }
        /// <summary>
        /// Computer to connect to
        /// </summary>
        /// <remarks>Hostname (or IP address) of computer to connect to</remarks>
        [DataMember]
        [Description("Hostname for computer to connect to")]
        public string Machine
        {
            get { return _machine; }
            set { _machine = value; }
        }
        /// <summary>
        /// Port number
        /// </summary>
        /// <remarks>TCP Port to connect to (usually 50001)</remarks>
        [DataMember]
        [Description("TCP Port to connect to (usually 50001)")]
        public ushort Port
        {
            get { return _port; }
            set { _port = value; }
        }
        /// <summary>
        /// Option settings from the GUI
        /// </summary>
        [DataMember]
        [Description("Option settings for the GUI")]
        public GUIOptions Options;
    }

    // TT - Version 2 - New class that is an "options bag" for the
    // option settings. An instance is added to the State above.
    /// <summary>
    /// GUIOptions -- Properties "bag" for option settings
    /// </summary>
    [DataContract]
    [DisplayName("GUI Option Settings")]
    [Description("Settings that control how the GUI appears")]
    public class GUIOptions
    {
        /// <summary>
        /// Initial X position of the Window in screen coords
        /// </summary>
        [DataMember]
        [Description("Initial X position of the Window in screen coords")]
        public int WindowStartX;
        /// <summary>
        /// Initial Y position of the Window in screen coords
        /// </summary>
        [DataMember]
        [Description("Initial Y position of the Window in screen coords")]
        public int WindowStartY;

        // Dead Zone parameters
        // The "deadzone" is a region where the movement of the
        // joystick has no effect. The implementation here snaps
        // the x or y coordinate to zero when it is within the
        // DeadZoneX or Y range. This allows the robot to drive
        // dead ahead, or to rotate perfectly. The old code did
        // not have an exact center and so the wheel power could
        // never be balanced!
        // For my Lego NXT, I use values of 80 for each of these.
        // This amounts to only a few pixels on the screen (because
        // the "yoke" range is +/- 1000). If you set it too high,
        // you won't get any movement! However, you can set it to
        // zero if you don't want this feature.
        /// <summary>
        /// X range at center of joystick that is "dead"
        /// </summary>
        [DataMember]
        public double DeadZoneX;
        /// <summary>
        /// Y range at center of joystick that is "dead"
        /// </summary>
        [DataMember]
        public double DeadZoneY;
        // Scale Factors
        // Because different robots have different drive
        // characteristics, and their users have different reaction
        // times and/or preferences, there are now two parameters
        // that affect the scaling of the drive power. The Translate
        // Scale Factor adjusts the forward/backward take-up rate,
        // i.e. moving the joystick forwards or backwards (which is
        // up or down on the "yoke" on the screen).
        // The Rotate Scale Factor adjusts the rate for the the
        // left/right (side to side) movements to control the speed
        // of rotation.
        // Usually you want different scale factors for these two
        // types of motions because it is hard to control turns if
        // the robot spins at the same speed that it uses to drives
        // forwards.
        // For my Lego NXT, I use values of 0.8 for Translate and
        // 0.2 for Rotate.
        //
        // NOTE: The results of the motor power calculations are
        // limited to +/- 1000, which translates to +/- 1.0 when
        // sent to the differentialdrive service. This means that
        // if you set Translate to 2.0 for instance, then it will
        // max out halfway between the center and the maximum
        // (top) of the joystick travel. This makes the speed much
        // more responsive to joystick movements. Conversely, you
        // can set a value of 0.5 and then the robot will only ever
        // reach half of its possible drive speed (approximately).
        /// <summary>
        /// Adjusts the sensitivity for driving forwards/backwards
        /// </summary>
        [DataMember]
        public double TranslateScaleFactor;
        /// <summary>
        /// Adjusts the sensitivity for rotating
        /// </summary>
        [DataMember]
        public double RotateScaleFactor;
        /// <summary>
        /// Show the LRF panel in the GUI window
        /// </summary>
        [DataMember]
        public bool ShowLRF;
        /// <summary>
        /// Show the Robotic Arm panel in the GUI window
        /// </summary>
        [DataMember]
        public bool ShowArm;

        // Added to support colour-coding of the LRF as per the code
        // supplied by Ben Axelrod
        /// <summary>
        /// Width of the robot for "3D" LRF display
        /// </summary>
        [DataMember]
        public double RobotWidth;

        // TT - May-2007 Version 6
        // Added to support displaying a top-down map
        /// <summary>
        /// Display LRF data as a top-down map
        /// </summary>
        [DataMember]
        public bool DisplayMap;
        /// <summary>
        /// Set the maximum range for the LRF
        /// </summary>
        [DataMember]
        public double MaxLRFRange;
        // TT - May-2007 Version 7
        // Values for use with RotateDegrees and DriveDistance
        // These are really intended for testing, not for actual use
        /// <summary>
        /// Set the "speed" for controlled moves (0-1000 maps to power of 0-1.0)
        /// </summary>
        [DataMember]
        public double MotionSpeed;
        /// <summary>
        /// Set the distance to travel for DriveDistance (in millimeters)
        /// </summary>
        [DataMember]
        public double DriveDistance;
        /// <summary>
        /// Angle for RotateDegrees (in degrees - duh!)
        /// </summary>
        [DataMember]
        public double RotateAngle;

        // TT - Jun-2007 Version 8
        /// <summary>
        /// Update interval for simulated camera -- OBSOLETE!
        /// </summary>
        [DataMember]
        public int CameraInterval;

    }

}
